<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>

    <script>

        // 统计字符串出现的次数
        var str='hello world! hello biden'
        var a={}
        // var newArr=[]
        for(var i=0;i<str.length;i++)
        {
            var code=str.charAt(i)
            if(a[code])
            {
                a[code]+=1
            }else{
                a[code]=1
            }
        }
        var max=0;
        char=""
        for(var i in a)
        {
            if(a[i]>max)
            {
                max=a[i]
               char=i
            }
        }
        console.log(a);
        console.log('出现次数最多的是:'+char+'字符'+max+'次');
   


       

    </script>
    
</body>
</html>